﻿using Microsoft.AspNetCore.DataProtection;

namespace TestDataProtectionApi
{
    public class ProtectDataClass
    {
        IDataProtector _dataProtector;
        public ProtectDataClass(IDataProtectionProvider dataProtectionProvider)
        {
            _dataProtector = dataProtectionProvider.CreateProtector("ProtectDataClass.v1");
        }
        public void RunSample()
        {
            var data = "Hello World";
            var protectedData = _dataProtector.Protect(data);
            Console.WriteLine($"Protected Data: {protectedData}");
            var unprotectedData = _dataProtector.Unprotect(protectedData);
            Console.WriteLine($"Unprotected Data: {unprotectedData}");
        }

        public string Protect(string data)
        {
            return _dataProtector.Protect(data);
        }
        public string Unprotect(string data)
        {
            return _dataProtector.Unprotect(data);
        }
    }
}
